﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VirtualOrg.Helper;

namespace VirtualOrg.Web.manage
{
    public partial class FormPopupMessage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["e"] == "1")
            {
                LoadSuccessMessage(Request.QueryString["t"]);
            }
            else
            {
                LoadErrorMessage(Request.QueryString["t"]);
            }
        }

        private void LoadSuccessMessage(string winType)
        {
            string actionurl = "";
            switch (winType.ToUpper())
            {
                case "TASK":
                    lblMessage.Text = "Task created successfully";
                    actionurl = "~/manage/CreateTask.aspx";
                    break;

                case "DEFECT":
                    lblMessage.Text = "Defect created successfully";
                    actionurl = "~/manage/CreateDefect.aspx";
                    break;

                case "TODO":
                    lblMessage.Text = "ToDo created successfully";
                    actionurl = "~/manage/CreateTodo.aspx";
                    break;
            }

            linkBack.NavigateUrl = actionurl;
        }

        private void LoadErrorMessage(string winType)
        {
            string actionurl = "";
            switch (winType.ToUpper())
            {
                case "TASK":
                    lblMessage.Text = "Error creating task. Please try again later!";
                    actionurl = "~/manage/CreateTask.aspx";
                    break;

                case "DEFECT":
                    lblMessage.Text = "Error creating defect. Please try again later!";
                    actionurl = "~/manage/CreateDefect.aspx";
                    break;

                case "TODO":
                    lblMessage.Text = "Error creating todo item. Please try again later!";
                    actionurl = "~/manage/CreateTodo.aspx";
                    break;

            }

            linkBack.NavigateUrl = actionurl;
        }
    }
}